<?php

namespace app\admin\model;

use think\Model;

class BusinessWalletLog extends Model
{
    // 表名
    protected $name = 'business_wallet_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [
        'change_type_text',
        'change_matters_text'
    ];
    

    
    public function getChangeTypeList()
    {
        return ['0' => __('Change_type 0'),'1' => __('Change_type 1')];
    }     

    public function getChangeMattersList()
    {
        return ['1' => __('Change_matters 1'),'2' => __('Change_matters 2'),'3' => __('Change_matters 3'),'4' => __('Change_matters 4'),'10' => __('Change_matters 10')];
    }     


    public function getChangeTypeTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['change_type'];
        $list = $this->getChangeTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getChangeMattersTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['change_matters'];
        $list = $this->getChangeMattersList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function businesswallet()
    {
        return $this->belongsTo('BusinessWallet', 'wallet_id', 'wallet_id', [], 'LEFT')->setEagerlyType(0);
    }
}
